<?php

if (!defined('L10N_CONFIG_DIR')) {
    define('L10N_CONFIG_DIR', dirname(__FILE__) . '/../../Config/Locale');    
}


class Adept_L10n_Locale {

  private $longMonthNames;
  private $shortMonthNames;
  private $longWeekdays;
  private $shortWeekdays;
  private $longDateFormat;
  private $shortDateFormat;
  private $longTimeFormat;
  private $shortTimeFormat;
  
  static private $locales = array();
  static private $currentLocale;
   
  function __construct($localeZone) {
  	
    $pathToLocaleSettings = ADEPT_L10N_CONFIG_DIR . '/';
    
    $fileName = $pathToLocaleSettings . 'locale.' . $localeZone . '.ini';
    $ini = new Adept_Config_Ini($fileName);
    
    $this->longMonthNames = $ini->getOption('long_month');  
    $this->shortMonthNames = $ini->getOption('short_month');  
    $this->longWeekdays = $ini->getOption('long_weekday');  
    $this->shortWeekdays = $ini->getOption('short_weekday');  
    $this->longDateFormat = $ini->getOption('long_date_format');  
    $this->shortDateFormat = $ini->getOption('short_date_format');
    $this->longTimeFormat = $ini->getOption('long_time_format');
    $this->shortTimeFormat = $ini->getOption('short_time_format');
  }
  
  static function getInstance($localeZone = '') {
    
    if (empty($localeZone)) {
      if (!self::$currentLocale) {
        self::$currentLocale = new Adept_L10n_Locale(DEFAULT_LOCALE);
      }
      return self::$currentLocale;
    }
    
    if (!self::$locales[$localeZone]) {
      self::$locales[$localeZone] = new Adept_L10n_Locale($localeZone);
    }
    return self::$locales[$localeZone];
  }
  
  static function setCurrentLocale($localeZone) {
  	self::$currentLocale = new Adept_L10n_Locale($localeZone);
  	return self::$currentLocale;
  }
  
  public function getLongMonthNames() {
    return $this->longMonthNames;
  }
  
  public function getShortMonthNames() {
  	return $this->shortMonthNames;
  }
  
  public function getLongWeekDays() {
  	return $this->longWeekdays;
  }
  
  public function getShortWeekDays() {
  	return $this->shortWeekdays;
  }
  
  public function getLongDateFormat() {
  	return $this->longDateFormat;
  }
  
  public function getShortDateFormat() {
  	return $this->shortDateFormat;
  }
  
  public function getLongTimeFormat() {
  	return $this->longTimeFormat;
  }
  
  public function getShortTimeFormat() {
  	return $this->shortTimeFormat;
  }
 
}
